package com.zt.enums;

/**
 * 优惠券类型枚举
 */
public enum CouponType {
    FIXED_AMOUNT(1, "固定金额"),
    PERCENTAGE(2, "百分比折扣"),
    FREE_SHIPPING(3, "免费配送");

    private final Integer code;
    private final String description;

    CouponType(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CouponType fromCode(Integer code) {
        for (CouponType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}
